﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		
		<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../../css/style.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="../../css/menu.css">

		<script src="../../script/jquery-3.3.1.min.js"></script>
		<script src="../../script/common.js"></script>
		<script src="../../../js/bootstrap.min.js"></script>
		<script src="../../../js/vue.js"></script>
	</head>
	<body>
	<div id="query">
		<div class="page_title">
			权限管理 > 用户管理 > 系统角色管理
		</div>
			<div class="button_bar">
				<button class="common_button" onclick="help();">
					帮助
				</button>
				<button class="common_button"
					onclick="to('add.html');">
					新建
				</button>
				<button class="common_button" @click="bylike();">
					查询
				</button>
			</div>
			<table class="query_form_table">
				<tr>
					<th>
						角色名
					</th>
					<td>
						<input type="text"  size="20" v-model="might.role_name">
					</td>
					<th>角色描述</th>
					<td>
						<input type="text"  size="20" v-model="might.role_desc">
					</td>
					<th>
						是否禁用
					</th>
					<td>
						<select v-model="might.role_flag">
							<option value="">全部</option>
							<option value="1">正常</option>
							<option value="0">禁用</option></select>
					</td>
				</tr>
			</table>
			<br />
			<table class="data_list_table">
				<tr>
					<th>
						编号
					</th>
					<th>
						角色名
					</th>
					<th>
						角色描述
					</th>
					<th>
						状态
					</th>
					<th>
						操作
					</th>
				</tr>
				
					<tr v-for="l in lists">
						<td class="list_data_text">
							{{l.role_id}}
						</td>
						<td class="list_data_text">
							{{l.role_name}}
						</td>
						<td>
							{{l.role_desc}}
						</td>
						<td class="list_data_text">
							<span v-if="l.role_flag==1">正常</span>
							<span v-if="l.role_flag==0">禁止</span>
						</td>
						<td class="list_data_op">
						
							<img @click="tos('edit.html',l.role_id)"
								title="编辑" src="../../images/bt_edit.gif" class="op_button" />
							<img @click="tos('roleRight.html',l.role_id)"
							    title="分配权限" src="../../images/bt_linkman.gif" class="op_button" />
						
							<img @click="tos('detail.html',l.role_id)"
								title="查看" src="../../images/bt_deal.gif" class="op_button" />
						
							<img
								@click="mydel(l.role_id)"
								title="删除" src="../../images/bt_del.gif" class="op_button" />
						</td>
					</tr>
				<tr>
					<th colspan="7" class="pager">
						<div>
							共{{pageInfo.total}}条记录 每页<input value="10" size="2" v-model="pageInfo.pageSize"/>条
							第<input value="1" size="2" v-model="pageInfo.pageNum"/>页/共{{pageInfo.pages}}页
							<a href="javascrip:;" @click="bylike(1)"> 第一页</a>
							<a href="javascrip:;" @click="bylike(pageInfo.pageNum-1)" :class="{'hidden':!pageInfo.hasPreviousPage}">上一页</a>
							<a href="javascrip:;" @click="bylike(pageInfo.pageNum+1)" :class="{'hidden':!pageInfo.hasNextPage}">下一页</a>
							<a href="javascrip:;" @click="bylike(pageInfo.pages)">最后一页</a>
							转到<input style="width: 20px"  v-model="pageInfo.pageNum"/>页
							<button  type="button" @click="bylike(pageInfo.pageNum)">GO</button>
						</div>
					</th>
				</tr>
			</table>
	</div>
	</body>
<script>
	var app = new Vue({
		el:'#query',
		data:{
            lists:[],
            pageInfo:'',
            might:{
                role_name:'',
				role_flag:'',
				role_desc:'',
                startPage:'',
                PageSize:''
            },
		},
		methods:{
            bylike(page){
                if(page<=0){
                    page=1;
                }
                if(page>=this.pageInfo.pages){
                    page=this.pageInfo.pages;
                }
                this.might.startPage=page;
                this.might.PageSize=this.pageInfo.pageSize;
                $.getJSON("/queryallSysRole",this.might,function (json) {
                    app.lists=json.data.pageInfo.list;
                    app.pageInfo=json.data.pageInfo;
                });
            },
            mydel(id){
				if(window.confirm("确认删除吗？")){
				    $.getJSON("/delSysRoleById/"+id,function (json) {
						if(json.code==200){
							alert("删除成功！！！");
							$.getJSON("/queryallSysRole",function (json) {
                                app.lists=json.data.pageInfo.list;
                                app.pageInfo=json.data.pageInfo;
                            });
						}else {
						    alert("服务区异常！！！")
						}
                    });
				}
			},
			tos(value,id){
                sessionStorage.setItem('rid',id)
				location=value;
			}
		},
		created(){
		    $.getJSON("/queryallSysRole",function (json) {
                app.lists=json.data.pageInfo.list;
                app.pageInfo=json.data.pageInfo;
            })
		}
	})
</script>
</html>

